package com.moniu.xzts.controller;

import jakarta.annotation.Resource;
import org.springframework.ai.chat.client.ChatClient;
import org.springframework.ai.deepseek.DeepSeekChatModel;
import org.springframework.core.io.ClassPathResource;
import org.springframework.util.MimeTypeUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping
public class ImageController {

    @Resource
    private  DeepSeekChatModel chatModel;

    @GetMapping("/image")
    public String image() {
        ChatClient chatClient = ChatClient.builder(chatModel).build();
        return chatClient
                .prompt()
                .user(u -> u.text("你能读这张图片里的文字吗?")
                        .media(MimeTypeUtils.IMAGE_PNG, new ClassPathResource("pay.jpg")))
                .call()
                .content() ;
    }
}
